/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.swirrel.listener;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.swirrel.util.MethodCall;
import org.swirrel.util.SwirrelException;

public class SwirrelChangeListener extends AbstractSwirrelListener implements ChangeListener {

    private final MethodCall stateChangedCall;

    public SwirrelChangeListener(MethodCall stateChangedCall) {
        this.stateChangedCall = stateChangedCall;
        if(! checkSignature(stateChangedCall, ChangeEvent.class)) {
            throw new SwirrelException("Method must have none or one ChangeEvent argument");
        }
    }

    public void stateChanged(ChangeEvent e) {
        call(stateChangedCall, e);
    }
}
